package com.rabbitmq.websocket;

import com.rabbitmq.entity.MessageEntity;
import com.rabbitmq.producer.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author ZH
 */
@RestController
@RequestMapping("/api/ws")
public class WebSocketController {
    @Autowired
    MessageService messageService;
    /**
     * 指定会话ID发消息
     * @return
     */
    @RequestMapping(value="/sendOne", method= RequestMethod.GET)
    public String sendOneMessage(){
        messageService.sendDirectMessage(MessageEntity.builder()
                .id(12345678L)
                .userId(1L)
                .deptId(100L)
                .message("hello~userId: 1 , deptId 100 !!!")
                .build());
        return "消息发送成功";
    }
}
